package cn.source.web.controller.tool;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiGettokenRequest;
import com.dingtalk.api.response.OapiGettokenResponse;
import com.taobao.api.ApiException;
public class AccessTokenUtil {
    public static String getToken() {
        try {
            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
            OapiGettokenRequest req = new OapiGettokenRequest();
            req.setAppkey("ding96bwmglductqrfwc");
            req.setAppsecret("SSy0L9oCaLqt9kBEQ_ey1a-ECdMG39ghHyO-11Nw0SpF8gfwMJ3p9REdtcVhjDA3");
            req.setHttpMethod("GET");
            OapiGettokenResponse rsp = client.execute(req);
            System.out.println(rsp.getBody());
            return rsp.getAccessToken();
        } catch (ApiException e) {
            e.printStackTrace();
            return null;
        }
    }
}
